package STUDENT.TranMinhVu.OOPS.ArrayExercises.Exercise5;

public class Models {
	public void Bubbledown(double[] array){
		for(int i=0; i< array.length-1; i++){
			for (int j=i+1; j<array.length; j++){
				if (array[i]>array[j]){
					double temp = array[i];
					array[i] = array[j];
					array[j] = temp;
				}
			}
		}
	}
	
	public void Selectionsort(double[] array){
		for(int i = array.length -1;i >=1; i--){
			double currentMax = array[0];
			int currentMaxindex = 0;
			for(int j=1; j<i;j++){
				if(currentMax<array[j]){
					currentMax=array[j];
					currentMaxindex=j;
				}
			}
			if(currentMaxindex!=i){
				array[currentMaxindex]=array[i];
				array[i] = currentMax;
			}
			
		}
	}
	
	public void Insertionsort(double[] array){
		for (int i=1; i < array.length; i++){
			double currentElement = array[i];
			int j;
			for (j=i-1;j>=0&&array[j]>currentElement;j--){
				array[j+1]=array[j];
			}
			array[j+1] = currentElement;
		}
	}
	
	public static void printArray(double[] array){
		for (int i=0; i<array.length;i++){
			System.out.println(array[i]+" ");
		}
	}
}
